package com.icinfo.cloud.provider.punish.common.publicsecurityentrust.dto;


import lombok.Data;

import javax.validation.Valid;
import javax.validation.constraints.Max;
import javax.validation.constraints.Min;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import java.util.List;

/**
 * 公安委托文号保存配置
 *
 * @author HKxxx
 * @date 2024/1/2 11:00
 */
@Data
public class PublicSecurityDocumentNumberReqDTO extends PublicSecurityDocumentNumberBaseDTO {
    /**
     * 剩余号段预警，超过999 默认存999
     */
//    @Length(min = 1,max = 3, message = "剩余号段预警仅限为0-999数字")
    @NotNull(message = "报警阈值不能为空")
    @Max(value = 999, message = "报警数最大为999")
    @Min(value = 0, message = "报警数最小为0")
    private Integer alarmNumber;

    /**
     * 拆分街道号段不能为空
     */
    @Valid
    @NotNull(message = "街道号段集合不能为空")
    @Size(min = 1, message = "街道号段至少拆分一条")
    List<PublicSecurityDocumentNumberSegmentSaveDTO> segments;

    /**
     * 校验参数
     */
    public void verify() {
        verifyNumber();
        segments.forEach(PublicSecurityDocumentNumberSegmentSaveDTO::verifyNumber);
    }
}
